package analysis.entity;

import java.io.Serializable;

/**
 * 〈氨基酸实体类〉
 *
 * @author shiweixian
 * @date 2018/3/8
 * @since 1.0.0
 */
public class AminoAcid implements Serializable, Comparable<AminoAcid> {
    /**
     * 氨基酸名字
     */
    private char name;
    /**
     * 比率
     */
    private double ratio;

    public char getName() {
        return name;
    }

    public void setName(char name) {
        this.name = name;
    }

    public double getRatio() {
        return ratio;
    }

    public void setRatio(double ratio) {
        this.ratio = ratio;
    }

    public int compareTo(AminoAcid o) {
        if (o == null) {
            return 0;
        } else if (ratio > o.getRatio()) {
            return -1;
        } else {
            return 1;
        }
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + name;
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        } else {
            return obj instanceof AminoAcid && name == ((AminoAcid) obj).getName();
        }
    }
}